-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: Add custom attribute for cookie header size #28890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add custom attribute for cookie header size #28890
Conversation
openedx/core/lib/request_utils.py
Outdated
| """ | ||
|
|
||
| if request.META.get('HTTP_COOKIE', None): | ||
| set_custom_attribute('cookies.header.size', len(request.META['HTTP_COOKIE'].encode('utf-8'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why the encode call? I guess that's measure bytes rather than characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
|
Your PR has finished running tests. There were no failures. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
Description
Report the total size of request cookie headers as a custom attribute to New Relic to provide observability into when cookie headers are reaching size limits. Calculated by getting the byte size of request.META['HTTP_COOKIE'], which is the raw string that eventually gets parsed into request.COOKIES (see https://github.com/django/django/blob/2fcafd169b5fcf4bb6711ca8aa4d59d80225ec7a/django/core/handlers/wsgi.py#L135)
The total size ends up being about ~100B more than just adding all the names and values in request.COOKIES, which makes sense considering the string representation has extra semi colons and quotation marks and other delineators.
Update description of CAPTURE_COOKIE_SIZE toggle to specify that it enables more detailed reporting than just the total size
Deadline
None